﻿#region File Header
/***********************************************************************
 * Copyright © 2013 Beals Software
 * All Rights Reserved
************************************************************************
Author: Donald Beals
Date: February 4th, 2013
Description: TODO: Write a description of this file here.
****************************** Change Log ******************************
02.04.13 - Created initial file. (dbeals)
***********************************************************************/
#endregion

#region Using Statements
using Newtonsoft.Json;
#endregion

namespace GameJolt.Requests
{
	/// <summary>
	/// 
	/// </summary>
	internal static class UserRequestFactory
	{
		[JsonObject]
		internal sealed class UserResult : IJsonResult<User[]>
		{
			IJsonResponse<User[]> IJsonResult<User[]>.Response
			{
				get
				{
					return Response;
				}
			}

			[JsonProperty("response")]
			public UserResponse Response
			{
				get;
				set;
			}
		}

		[JsonObject]
		internal sealed class UserResponse : IJsonResponse<User[]>
		{
			User[] IJsonResponse<User[]>.ResultSet
			{
				get
				{
					return Users;
				}
			}

			[JsonProperty("success")]
			public string WasSuccessful
			{
				get;
				set;
			}

			[JsonProperty("message")]
			public string Message
			{
				get;
				set;
			}

			[JsonProperty("users")]
			public User[] Users
			{
				get;
				set;
			}
		}

		public static JsonRequest<User[], UserResult> CreateGetRequest(string gameID, string publicKey, string username)
		{
			return new JsonRequest<User[], UserResult>(gameID, publicKey, Constants.UserUrls.GetUrl, RequestParameter.CreateUsername(username));
		}

		public static JsonRequest<User[], UserResult> CreateGetRequest(string gameID, string publicKey, params string[] userIDs)
		{
			return new JsonRequest<User[], UserResult>(gameID, publicKey, Constants.UserUrls.GetUrl, RequestParameter.CreateUserID(userIDs));
		}

		public static StringRequest CreateAuthRequest(string gameID, string publicKey, string username, string userToken)
		{
			return new StringRequest(gameID, publicKey, Constants.UserUrls.AuthUrl, RequestParameter.CreateUsername(username), RequestParameter.CreateUserToken(userToken));
		}
	}
}
